Cost-analysis: How do monads and comonads differ?
نویسندگان
چکیده
Monads are a de facto standard for the type-based analysis of impure aspects of programs, such as runtime cost [9, 5]. Recently, the logical dual of a monad, the comonad, has also been used for the cost analysis of programs, in conjunction with a linear type system [6, 8]. The logical duality of monads and comonads extends to cost analysis: In monadic type systems, costs are (side) effects, whereas in comonadic type systems, costs are coeffects. However, it is not clear whether these two methods of cost analysis are related and, if so, how. Are they equally expressive? Are they equally well-suited for cost analysis with all reduction strategies? Are there translations from type systems with effects to type systems with coeffects and viceversa? The goal of this work-in-progress paper is to explore some of these questions in a simple context — the simply typed lambda-calculus (STLC). As we show, even this simple context is already quite interesting technically and it suffices to bring out several key points.
منابع مشابه
Coeffects: Unified Static Analysis of Context-Dependence
Monadic effect systems provide a unified way of tracking effects of computations, but there is no unified mechanism for tracking how computations rely on the environment in which they are executed. This is becoming an important problem for modern software – we need to track where distributed computations run, which resources a program uses and how they use other capabilities of the environment....
متن کاملCoherence for monoidal monads and comonads
The goal of this paper is to prove coherence results with respect to relational graphs for monoidal monads and comonads, i.e. monads and comonads in a monoidal category such that the endofunctor of the monad or comonad is a monoidal functor (this means that it preserves the monoidal structure up to a natural transformation that need not be an isomorphism). These results are proved first in the ...
متن کاملA Notation for Comonads
The category-theoretic concept of a monad occurs widely as a design pattern for functional programming with effects. The utility and ubiquity of monads is such that some languages provide syntactic sugar for this pattern, further encouraging its use. We argue that comonads, the dual of monads, similarly provide a useful design pattern, capturing notions of context dependence. However, comonads ...
متن کاملShould I use a Monad or a Comonad ?
The category theoretic structures of monads and comonads can be used as an abstraction mechanism for simplifying both language semantics and programs. Monads have been used to structure impure computations, whilst comonads have been used to structure context-dependent computations. Interestingly, the class of computations structured by monads and the class of computations structured by comonads...
متن کاملRegular Pairings of Functors and Weak (co)monads
For functors L : A→ B and R : B→ A between any categories A and B, a pairing is defined by maps, natural in A ∈ A and B ∈ B, MorB(L(A), B) α // MorA(A,R(B)) β oo . (L,R) is an adjoint pair provided α (or β) is a bijection. In this case the composition RL defines a monad on the category A, LR defines a comonad on the category B, and there is a well-known correspondence between monads (or comonad...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2016